<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_class" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="popAddBigProcessClass('')" type='success' size="mini"><i class='fa fa-plus'></i>增加分类</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 工序分类 </span>
      </div>
      <el-table :data="s_class">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_class('&CMIDpro_produce_id='+scope.row.pro_produce_id+'')">删除</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popUpProcessClass('&CMIDpro_produce_id='+scope.row.pro_produce_id+'')">修改</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popAddSonProcessClass('&CMIDpro_produce_id='+scope.row.pro_produce_id+'')">增加子分类</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="分类" prop="">
          <template slot-scope="scope">
            <span v-html="scope.row.__desc"></span>
            {{scope.row.pro_produce_name}}
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="AddBigProcessClassVisible" append-to-body>
      <AddBigProcessClass v-if="AddBigProcessClassVisible" ref="AddBigProcessClass" :popparams="popparams"> </AddBigProcessClass>
    </el-dialog>
    <el-dialog :visible.sync="UpProcessClassVisible" append-to-body>
      <UpProcessClass v-if="UpProcessClassVisible" ref="UpProcessClass" :popparams="popparams"> </UpProcessClass>
    </el-dialog>
    <el-dialog :visible.sync="AddSonProcessClassVisible" append-to-body>
      <AddSonProcessClass v-if="AddSonProcessClassVisible" ref="AddSonProcessClass" :popparams="popparams"> </AddSonProcessClass>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import AddBigProcessClass from "@/views/mes/product/AddBigProcessClass";
  import UpProcessClass from "@/views/mes/product/UpProcessClass";
  import AddSonProcessClass from "@/views/mes/product/AddSonProcessClass";
  export default {
    name: 'ProcessClass',
    components: {
      AddBigProcessClass,
      UpProcessClass,
      AddSonProcessClass,
    },
    props: ['popparams'],
    data() {
      return {
        AddBigProcessClassVisible: false,
        AddBigProcessClassValue: null,
        AddBigProcessClassDesc: null,
        UpProcessClassVisible: false,
        UpProcessClassValue: null,
        UpProcessClassDesc: null,
        AddSonProcessClassVisible: false,
        AddSonProcessClassValue: null,
        AddSonProcessClassDesc: null,
        vueparams: this.getVUEParams(""),
        s_class: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/ProcedureAction/processClass?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
          this["s_class"] = this.loadTreeTable(this["s_class"], "pro_produce_id", "pro_produce_parent");
        })
      },
      d_class(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/product/ProcedureAction/d_class?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popAddBigProcessClass(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddBigProcessClassVisible = !this.AddBigProcessClassVisible;
      },
      popUpProcessClass(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.UpProcessClassVisible = !this.UpProcessClassVisible;
      },
      popAddSonProcessClass(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddSonProcessClassVisible = !this.AddSonProcessClassVisible;
      },
    },
  }
</script>
